package adapters;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.newxlmedical.CountActivity;
import com.example.administrator.newxlmedical.CountGoodsDetialActivity;
import com.example.administrator.newxlmedical.R;

import java.util.List;

import beans.CountGoodsDetailInfoBean;
import beans.GoodsStatisticsBean;
import butterknife.BindView;
import constants.Constants;
import custom.BaseRecyclerAdapter;

/**
 * Created by Administrator on 2018/5/8.
 */

public class CountAdapter extends BaseRecyclerAdapter<CountAdapter.CountViewHolder> {
    private Context mContext;
    private LayoutInflater inflater;
    private List<GoodsStatisticsBean.DataBean> list;
//    private OnClickListener onClickListener;

    private int PurchaseCount;
    private int ApplyCount;
    private int StockCount;
    private int TakeOutCount;
    private int NotReturnedCount;
    private String starTime;
    private String endTime;
    public CountAdapter(Context mContext, List<GoodsStatisticsBean.DataBean> list) {
        this.mContext = mContext;
        this.list = list;
        inflater=LayoutInflater.from(mContext);
    }

    @Override
    public CountViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        CountViewHolder viewHolder = new CountViewHolder(inflater.inflate(R.layout.adapter_count, parent, false));
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(final CountViewHolder viewHolder, final int position) {
        GoodsStatisticsBean.DataBean bean = list.get(position);
        viewHolder.tvGoodsName.setText(bean.getGoodName());
        viewHolder.tvGoodsSpecification.setText(bean.getSpecification());
        viewHolder.tvSupplier.setText(bean.getManufacturer());
        viewHolder.tvPurchase.setText(String.valueOf(bean.getPurchaseCount()));
        viewHolder.tvUse.setText(String.valueOf(bean.getStockCount()));
        viewHolder.tvStorage.setText(String.valueOf(bean.getTakeOutCount()));
        viewHolder.tvReturn.setText(String.valueOf(bean.getApplyCount()));
        viewHolder.tvNotReturn.setText(String.valueOf(bean.getNotReturnedCount()));

        if (position % 2 == 0) {
            viewHolder.llTitle.setBackgroundColor(mContext.getResources().getColor(R.color.partLineBackground));
        } else {
            viewHolder.llTitle.setBackgroundColor(mContext.getResources().getColor(R.color.white));
        }

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class CountViewHolder extends BaseRecyclerAdapter.BaseViewHolder {
        @BindView(R.id.tv_adapter_count_goods_name)
        TextView tvGoodsName;
        @BindView(R.id.tv_adapter_count_goods_specification)
        TextView tvGoodsSpecification;
        @BindView(R.id.tv_adapter_count_supplier)
        TextView tvSupplier;
        @BindView(R.id.tv_adapter_count_purchase)
        TextView tvPurchase;
        @BindView(R.id.tv_adapter_count_use)
        TextView tvUse;
        @BindView(R.id.tv_adapter_count_storage)
        TextView tvStorage;
        @BindView(R.id.tv_adapter_count_return)
        TextView tvReturn;
        @BindView(R.id.tv_adapter_count_not)
        TextView tvNotReturn;
        @BindView(R.id.ll_adapter_count)
        LinearLayout llTitle;

        public CountViewHolder(View itemView) {
            super(itemView);
        }
    }

}
